//引入文件模块
let fs = require("fs");//file system

// console.log(fs);

fs.readFile("1.txt", "utf-8", function (err, data) {
    console.log(err, data);
});

// fs.readFile("D:\\devtool\\workspace\\webstorm\\lingshi2018_web\\NodeJS\\01-概述\\01-表单的post提交.html", "utf-8", function (err, data) {
//     console.log(err, data);
// });

//相对路径：需要特别注意的是，路径是相对node命令执行的目录
// fs.readFile("../../01-概述/01-表单的post提交.html", "utf-8", function (err, data) {
//     console.log(err, data);
// });

fs.writeFile('1.txt', "这是FS写入的内容", (err) => {
    if (err) throw err;
    console.log('The file has been saved!');
});

fs.appendFile('1.txt', "这是FS附加的内容", (err) => {
    if (err) throw err;
    console.log('The file has been saved!');
});